package com.erp.system.service.impl;

import com.erp.system.domain.Vendor;
import com.erp.system.mapper.VendorMapper;
import com.erp.system.service.VendorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
  * FileName: VendorServiceImpl.java
  * 业务层接口实现类的详细说明
  *
  * @author  类创建者姓名
  * @Date    创建日期
  * @version 1.00
*/
@Service
public class VendorServiceImpl implements VendorService {

    @Autowired
    private VendorMapper vendorMapper;


    @Override
    public List<Vendor> queryAll(Vendor vendor) {
        return vendorMapper.queryAll(vendor);
    }

    @Override
    public int insertVendor(Vendor vendor) {
        return vendorMapper.insertVendor(vendor);
    }

    @Override
    public Vendor queryById(String id) {
        return vendorMapper.queryById(id);
    }

    @Override
    public int updateVendor(Vendor vendor) {
        return vendorMapper.updateVendor(vendor);
    }

    @Override
    public int deleteVendorByIds(String[] id) {
        return vendorMapper.deleteVendorByIds(id);
    }

    @Override
    public boolean checkCodeUnique(Vendor vendor) {
        Vendor param = new Vendor();
        param.setCode(vendor.getCode());
        List<Vendor> list = queryAll(param);
        return !list.isEmpty() && list.stream().noneMatch(c -> c.getId().equals(vendor.getId()));
    }
}
